package com.zhuchang.self_rpc.test.provider;

import com.zhuchang.self_rpc.test.config.ProviderConfig;
import com.zhuchang.self_rpc.test.config.RpcServerConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author RenPu
 * @Date 2021/8/19 10:40
 * @Version 1.0
 * @Description: 服务提供者的starter类
 **/
public class ProviderStarter {


    public static void main(String[] args) {

        new Thread(new Runnable() {
            public void run() {
                try {
                    //1：每一个服务提供者的配置类
                    ProviderConfig providerConfig = new ProviderConfig();
                    providerConfig.setInterfaceClass("com.zhuchang.self_rpc.test.consumer.HelloService");
                    HelloServiceImpl helloServiceimpl = HelloServiceImpl.class.newInstance();
                    providerConfig.setRef(helloServiceimpl);

                    //把服务提供者的配置类封装到集合
                    List<ProviderConfig> providerConfigs = new ArrayList<ProviderConfig>();
                    providerConfigs.add(providerConfig);


                    RpcServerConfig rpcServerConfig = new RpcServerConfig(providerConfigs);
                    rpcServerConfig.setPort(8848);
                    rpcServerConfig.exporter();
                } catch (Throwable e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }


}
